//@ts-check
/**@type {string[]} */
const arrKey = [];
/**@type {string[]} */
const arrValue = [];
const { isArray } = Array;
for (const key in process) {

  if (['dlopen', 'reallyExit', '_debugEnd', 'abort', 'moduleLoadList', 'uptime', 'cwd', 'title', 'pid', 'ppid', 'execPath', 'debugPort', 'argv0', 'version', 'assert', 'domain',
    'getActiveResourcesInfo', //node12不支持
    'constrainedMemory' //node12不支持
  ].includes(key) || key.startsWith('_')) {
    continue;
  }
  // console.log(key);

  try {
    const value = process[key];
    const typeofValue = typeof value;
    switch (typeofValue) {
      case 'bigint':
      case 'boolean':
      case 'number':
        {
          arrKey.push(key);
          arrValue.push(`${key}===${value}`);
          break;
        }
      case 'string':
        {
          arrKey.push(key);
          arrValue.push(`${key}==='${value}'`);
          break;
        }

      case 'undefined': {
        arrKey.push(key);
        arrValue.push(`${key}===undefined`);
        break;
      }
      case 'object': {
        if (isArray(value)) {
          arrKey.push(key);
          arrValue.push(`isArray(${key})`);
        } else if (value === null) {
          arrKey.push(key);
          arrValue.push(`${key}===null`);
        } else {
          // console.log(value);
        }
        break;
      }
      case 'function':
        {
          /**@type {Function} */
          const func = value;
          if (func.length === 0) {
            // console.log(key);
            const value = process[key]();
            const typeofValue = typeof value;
            switch (typeofValue) {
              case 'bigint':
              case 'boolean':
              case 'number':
                {
                  // arrKey.push(key);
                  arrValue.push(`process.${key}()===${value}`);
                  break;
                }
              case 'string':
                {
                  // arrKey.push(key);
                  arrValue.push(`process.${key}()==='${value}'`);
                  break;
                }

              case 'undefined': {
                // arrKey.push(key);
                arrValue.push(`process.${key}()===undefined`);
                break;
              }
              case 'object': {
                if (isArray(value)) {
                  // arrKey.push(key);
                  arrValue.push(`isArray(process.${key}())`);
                } else if (value === null) {
                  arrValue.push(`process.${key}()===null`);
                }
                break;
              }
              case 'function':
              case "symbol":
                {
                  console.log(key);
                  break;
                }

            }
          }
          break;
        }
      case "symbol":
        {
          console.log(key);
          break;
        }
    }
  } catch (e) {
    console.log(key);
    console.error(e);
  }
}
console.log(arrKey.join(','));
console.log(arrValue.map(i => i.replace(/\\/g, '/')).join('&&'));

